package com.bitcoin.scheduler.websocket.client.gateio;

import com.bitcoin.scheduler.websocket.client.gateio.impl.GateIoApiWebSocketClientImpl;

import static com.bitcoin.scheduler.websocket.client.ApiServiceGenerator.getSharedClient;

/**
 * A factory for creating BinanceApi client objects.
 */
public class GateIoApiClientFactory {

    public static GateIoApiClientFactory instance1;
    public static GateIoApiClientFactory instance2;
    public static GateIoApiWebSocketClient client;
    /**
     * API Key
     */
    private String apiKey;

    /**
     * Secret.
     */
    private String secret;

    /**
     * New instance.
     *
     * @param apiKey the API key
     * @param secret the Secret
     * @return the binance api client factory
     */
    public static GateIoApiClientFactory newInstance(String apiKey, String secret) {
        return new GateIoApiClientFactory(apiKey, secret);
    }

    /**
     * New instance without authentication.
     *
     * @return the binance api client factory
     */
    public static GateIoApiClientFactory newInstance() {
        if (instance1 == null) {
            instance1 = new GateIoApiClientFactory(null, null);
        }
        return instance1;
    }

    /**
     * Instantiates a new binance api client factory.
     *
     * @param apiKey the API key
     * @param secret the Secret
     */
    private GateIoApiClientFactory(String apiKey, String secret) {
        this.apiKey = apiKey;
        this.secret = secret;
    }

    /**
     * Creates a new web socket client used for handling data streams.
     */
    public GateIoApiWebSocketClient newWebSocketClient() {
        if (client == null) {
            client = new GateIoApiWebSocketClientImpl(getSharedClient());
        }
        return client;
    }
}
